﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using WCFAgencia;
using WCFAlojamento;
using WCFCliente;
using WCFLocal;



public partial class viagens : System.Web.UI.Page
{
    protected WCFAgencia.WCFAgenciaClient wcfAgencia = new WCFAgencia.WCFAgenciaClient();
    protected WCFCliente.WCFClienteClient wcfCliente = new WCFCliente.WCFClienteClient();
    protected WCFLocal.WCFLocalClient WCFLocal = new WCFLocal.WCFLocalClient();


    protected void Page_Load(object sender, EventArgs e)
    {
        if (Session["nome"] == null)
        {
            Response.Redirect("login.aspx");
        }
        
    }

    protected void GridView1_SelectedIndexChanged(object sender, EventArgs e)
    {

    }

    protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            int idAgencia = int.Parse(e.Row.Cells[0].Text);
            int idCliente = int.Parse(e.Row.Cells[1].Text);
            int idPartida = int.Parse(e.Row.Cells[2].Text);
            int idChegada = int.Parse(e.Row.Cells[3].Text);
            HyperLink link = (HyperLink)(e.Row.Cells[7].FindControl("link"));
            //link.NavigateUrl = "detalhes.aspx?id=" + e.Row.

            Agencia agencia = wcfAgencia.getByID(idAgencia);
            e.Row.Cells[0].Text = agencia.nome;

            Cliente cliente = wcfCliente.getByID(idCliente);
            e.Row.Cells[1].Text = cliente.nome;

            Local origem = WCFLocal.getByID(idPartida);
            e.Row.Cells[2].Text = origem.nome;

            Local destino = WCFLocal.getByID(idChegada);
            e.Row.Cells[3].Text = destino.nome;
        }
    }
}
